package com.example.courseservice.config.rabbitmq;

import cn.hutool.json.JSONUtil;
import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component
public class MqConsumer {
  /*  @RabbitListener(queues = "simple.queue")
    public void listenSimpleQueueMessage(String msg) throws InterruptedException {
        System.out.println("spring 消费者接收到消息 ：【" + msg + "】");
    }


    @RabbitListener(queues = "fanout.queue1")
    public void fq1(String msg) throws InterruptedException {
        System.out.println("spring 消费者接收到【fanout.queue1】消息 ：【" + msg + "】");
    }

    @RabbitListener(queues = "fanout.queue2")
    public void fq2(String msg) throws InterruptedException {
        System.out.println("spring 消费者接收到【fanout.queue2】消息 ：【" + msg + "】");
    }

    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(name = "direct.queue1"),
            exchange = @Exchange(
                    name = "direct.exchange",
                    type = ExchangeTypes.DIRECT
            ),
            key = {"red","blue"}
    ))
    public void dc1(String msg) throws InterruptedException {
        System.out.println("spring 消费者接收到【DIRECT.queue1】消息 ：【" + msg + "】");
    }

    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(name = "direct.queue2"),
            exchange = @Exchange(
                    name = "direct.exchange",
                    type = ExchangeTypes.DIRECT
            ),
            key = {"yellow","red"}
    ))
    public void dc2(String msg) throws InterruptedException {
        System.out.println("spring 消费者接收到【DIRECT.queue2】消息 ：【" + msg + "】");
    }


    @RabbitListener(queues = "object.queue")
    public void bjq1(Map<String,Object> msg) throws InterruptedException {
        System.out.println("spring 消费者接收到消息 ：【" + msg.get("name") + "】");
    }*/
}
